﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ListenMusic.Song_ServiceReference;
using System.ServiceModel;
using ListenMusic.Models.ViewModel;
namespace ListenMusic.Models.Public
{
    public class SongRepository
    {        
        SongServiceClient song_client = new SongServiceClient("ws_songservice");
        public DataContract_Song getSongById(int id)
        {
            return song_client.getSongByID(id);
        }
        public List<Song> getSongByAlbumID(int id)
        {
            try
            {
                Song[] song = song_client.getSongByAlbumID(id);
                return song.ToList();
            }
            catch (FaultException ex)
            {
                throw ex;
            }
        }
        public List<DataContract_Song> getTopSong(int number, int type)
        {
            try
            {
                DataContract_Song[] song = song_client.getTopSong(number, type);
                return song.ToList();
            }
            catch (FaultException ex)
            {
                throw ex;
            }
        }
        //public List<SongSingerDetails> getTopSong(int number, int type)
        //{ 
        //    try
        //    {
        //        List<SongSingerDetails> details = new List<SongSingerDetails>();
        //        Song[] song = song_client.getAllSong();
        //        for (int i = 0; i < song.Length; i++)
        //        {
        //            details[i].AlbumID = Convert.ToInt32(song[i].AlbumID);
        //            details[i].SingerID = Convert.ToInt32(song[i].SingerID);
        //        }

        //        return details.ToList();
        //    }
        //    catch (FaultException ex)
        //    {
        //        throw ex;
        //    }
        //}
        public List<DataContract_Song> getnewSong(int number)
        {
            try
            {
                DataContract_Song[] song = song_client.getnewSong_Singer(number);
                return song.ToList();
            }
            catch (FaultException ex)
            {
                throw ex;
            }
        }
        public List<Song> getSongBySinger(string singerName)
        {
            try
            {
                Song[] song = song_client.getSongBySingerName(singerName);
                return song.ToList();
            }
            catch (FaultException ex)
            {
                throw ex;
            }
        }
    }
}